<?php
/**
* Handles the control panel.
*/
if(defined('IZ_ACCNAME')) {
  include_once($_SESSION['IZ_CALPATH'].'includes/lang/'.$_SESSION['IZ_LANG'].'_admin.php'); ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  
  <head profile="http://gmpg.org/xfn/11">
  
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title><?php echo $_SESSION['IZ_CALNAME']." &#187; ".STR_CPANEL; ?></title>
  <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['IZ_CALURL']; ?>includes/main.css" />
  <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['IZ_CALURL']; ?>includes/admin.css" />
  <?php if($_GET['page'] == 'themes' || $_GET['page'] == 'users') { 
    echo '<script type="text/javascript" src="',$_SESSION['IZ_CALURL'],'includes/lib/prototype.js"></script>
    <script type="text/javascript" src="',$_SESSION['IZ_CALURL'],'includes/lib/scriptaculous.js"></script>
    <script type="text/javascript" src="',$_SESSION['IZ_CALURL'],'includes/lib/yahoo.color.js"></script>
    <script type="text/javascript" src="',$_SESSION['IZ_CALURL'],'includes/js/colorpick.js"></script>
    <link rel="stylesheet" type="text/css" href="',$_SESSION['IZ_CALURL'],'includes/colorpick.css" />
    ';
   } ?>
  <script type="text/javascript" src="<?php echo $_SESSION['IZ_CALURL']; ?>includes/js/onload.js"></script>
  <script type="text/javascript" src="<?php echo $_SESSION['IZ_CALURL']; ?>includes/js/main.js"></script>
  <script type="text/javascript" src="<?php echo $_SESSION['IZ_CALURL']; ?>includes/js/admin.js"></script>
  <script type="text/javascript">
  var izimgdir = '<?php echo $_SESSION['IZ_CALURL']; ?>images/';
  function validate_admin() {
    var valid = true;
      <?php if($_GET['page'] == 'calsetup') { ?>
          document.getElementById('error_calurl').style.display = 'none';
          if(document.admin.calurl.value == "") {
              document.getElementById('error_calurl').innerHTML = '<?php echo ERR_NOCALURL; ?>';
              document.getElementById('error_calurl').style.display = 'inline';
              valid = false;
          }  
          document.getElementById('error_invites').style.display = 'none';
          if(document.admin.gmailinv.checked) {
            if((document.admin.IZ_GMAIL_ACC.value == "") || (document.admin.IZ_GMAIL_PWD.value == "")) {
              document.getElementById('error_invites').innerHTML = '<?php echo ERR_GMAILACC; ?>';
              document.getElementById('error_invites').style.display = 'block';
              valid = false;
            }
          }        
          document.getElementById('error_cust1').style.display = 'none';
          if(document.admin.cust1on.checked) {
            if(document.admin.cust1name.value == "") {
              document.getElementById('error_cust1').innerHTML = '<?php echo ERR_CUSTFIELDBLANK; ?>';
              document.getElementById('error_cust1').style.display = 'block';
              valid = false;
            }
          }
          document.getElementById('error_cust2').style.display = 'none';
          if(document.admin.cust2on.checked) {
            if(document.admin.cust2name.value == "") {
              document.getElementById('error_cust2').innerHTML = '<?php echo ERR_CUSTFIELDBLANK; ?>';
              document.getElementById('error_cust2').style.display = 'block';
              valid = false;
            }
          }
          document.getElementById('error_cust3').style.display = 'none';
          if(document.admin.cust3on.checked) {
            if(document.admin.cust3name.value == "") {
              document.getElementById('error_cust3').innerHTML = '<?php echo ERR_CUSTFIELDBLANK; ?>';
              document.getElementById('error_cust3').style.display = 'block';
              valid = false;
            }
          }        
       <?php } elseif($_GET['page'] == 'system') { ?>   
          document.getElementById('error_dbhost').style.display = 'none';
          document.getElementById('error_dbuser').style.display = 'none';
          document.getElementById('error_dbdatabase').style.display = 'none';
          if((document.admin.mysqlmode.checked) || (document.admin.postgremode.checked) || (document.admin.msqmode.checked)) {
              if(document.admin.dbhost.value == "") {
                  document.getElementById('error_dbhost').innerHTML = '<?php echo ERR_SQLHOSTBLANK; ?>';
                  document.getElementById('error_dbhost').style.display = 'inline';                
                  valid = false;
              }
              if(document.admin.dbuser.value == "") {
                  document.getElementById('error_dbuser').innerHTML = '<?php echo ERR_SQLUSERBLANK; ?>';
                  document.getElementById('error_dbuser').style.display = 'inline';                
                  valid = false;
              }
              if(document.admin.dbdatabase.value == "") {
                  document.getElementById('error_dbdatabase').innerHTML = '<?php echo ERR_SQLDBBLANK; ?>';
                  document.getElementById('error_dbdatabase').style.display = 'inline';                
                  valid = false;
              }                                    
          }
          <?php } ?>
          return valid;
  }
  </script>
  <!--[if IE]>
  <link rel="stylesheet" type="text/css" href="includes/ie.css" />
  <![endif]--> 
  </head>
  <body<?php if($_GET['page'] == 'calsetup') { echo ' onload="setdisabled()"'; } ?>>
  <div id="adminwrap">
  <div id="bannerback"><a href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" id="banner">Control Panel Home</a></div>
  <table id="adminwrapper">
    <tr>
      <td id="menu">
        <div id="adminmenu">
          <ul>
            <li><a <?php if((!isset($_GET['page'])) && ($_POST['setadmin'] != 'Restore')) { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin" title="<?php echo ADM_CPANELHOME; ?>"><?php echo ADM_CPANELHOME; ?></a></li>
            <li><a <?php if($_GET['page'] == 'calsetup') { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin&amp;page=calsetup" title="<?php echo ADM_CALSETUP; ?>"><?php echo ADM_CALSETUP; ?></a></li>
            <li><a <?php if($_GET['page'] == 'local') { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin&amp;page=local" title="<?php echo ADM_LOCAL; ?>"><?php echo ADM_LOCAL; ?></a></li>
            <li><a <?php if($_GET['page'] == 'themes') { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin&amp;page=themes" title="<?php echo ADM_THEMES; ?>"><?php echo ADM_THEMES; ?></a></li>
            <li><a <?php if($_GET['page'] == 'users') { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin&amp;page=users" title="<?php echo ADM_USERS; ?>"><?php echo ADM_USERS; ?></a></li>
            <li><a <?php if(($_GET['page'] == 'backup') || ($_POST['setadmin'] == 'Restore')) { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin&amp;page=backup" title="<?php echo ADM_BACKUP; ?>"><?php echo ADM_BACKUP; ?></a></li>
            <li><a <?php if($_GET['page'] == 'system') { echo 'id="active" '; } ?>href="<?php echo $_SESSION['IZ_CALURL']; ?>index.php?act=admin&amp;page=system" title="<?php echo ADM_SYSTEM; ?>"><?php echo ADM_SYSTEM; ?></a></li>
          </ul>
        </div>
      </td>
      <td style="padding: 5px;"></td>
      <td id="content" valign="top">
  <?php
  if(!empty($_GET['page'])) {
    $page = $_GET['page'];
    if($page == 'local') {
  ?>    
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin">
          <div class="containerbox">
          <div class="containertitle"><?php echo ADM_LOCAL; ?></div>
  
          <div id="warningbox" style="margin: 10px auto;">iZeit needs translators for other languages. If you can speak another language to a near fluent level and want to contribute, please go to
          <a href="http://forums.lime49.com/viewtopic.php?f=7&amp;t=86">this thread</a> in the forums and let us know.</div>
          <label for="lang"><?php echo ADM_LANGTITLE; ?>&#58;</label>
            <select name="lang" id="lang">
             <option <?php if($_SESSION['IZ_LANG'] == 'cs') { echo 'selected="selected" '; } ?>value="cs">&#268;esky</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'de') { echo 'selected="selected" '; } ?>value="de">Deutsch</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'el') { echo 'selected="selected" '; } ?>value="el">&#917;&#955;&#955;&#951;&#957;&#953;&#954;&#945;</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'en') { echo 'selected="selected" '; } ?>value="en">English</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'es') { echo 'selected="selected" '; } ?>value="es">Espa&#241;ol</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'fr') { echo 'selected="selected" '; } ?>value="fr">Fran&#231;ais</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'hr') { echo 'selected="selected" '; } ?>value="hr">Hrvatski Jezik</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'it') { echo 'selected="selected" '; } ?>value="it">Italiano</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'ka') { echo 'selected="selected" '; } ?>value="ka">&#4325;&#4304;&#4320;&#4311;&#4323;&#4314;&#4312;&#32;</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'nl') { echo 'selected="selected" '; } ?>value="nl">Nederlands</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'pl') { echo 'selected="selected" '; } ?>value="pl">Polski</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'pt') { echo 'selected="selected" '; } ?>value="pt">Portugu&#234;s</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'ro') { echo 'selected="selected" '; } ?>value="ro">&#4325;&#4304;&#4320;&#4311;&#4323;&#4314;&#4312;&#32;</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'ru') { echo 'selected="selected" '; } ?>value="ru">&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'sl') { echo 'selected="selected" '; } ?>value="sl">Slovensko</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'sr-Cyrl-CS') { echo 'selected="selected" '; } ?>value="sr-Cyrl-CS">&#1057;&#1088;&#1087;&#1089;&#1082;&#1080; &#1032;&#1077;&#1079;&#1080;&#1082;</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'sr-Latn-CS') { echo 'selected="selected" '; } ?>value="sr-Latn-CS">Srpski Jezik</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'sv') { echo 'selected="selected" '; } ?>value="sv">Sverige</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'tr') { echo 'selected="selected" '; } ?>value="tr">T&#252;rkçe</option>
             <option <?php if($_SESSION['IZ_LANG'] == 'zh-CHS') { echo 'selected="selected" '; } ?>value="zh-CHS">&#31616;&#20307;&#23383;</option>
             </select><br />
       <?php /*  < <label for="time"><?php echo ADM_TIMEOFFSET; ?>&#58;</label>
          <select name="timezone" id="time" size="1">
          <?php
       $timezones = array(
                  '-12' => '(- 12:00 hours) &#58; '.iz_longdatehours($servertime-43200),
      '-11' => '(- 11:00 hours) &#58; '.iz_longdatehours($servertime-39600),
      '-10' => '(- 10:00 hours) &#58; '.iz_longdatehours($servertime-36000),
      '-9' => '(- 9:00 hours) &#58; '.iz_longdatehours($servertime-32400),
      '-8' => '(- 8:00 hours) &#58; '.iz_longdatehours($servertime-28800),
      '-7' => '(- 7:00 hours) &#58; '.iz_longdatehours($servertime-25200),
      '-6' => '(- 6:00 hours) &#58; '.iz_longdatehours($servertime-21600),
      '-5' => '(- 5:00 hours) &#58; '.iz_longdatehours($servertime-18000),
      '-4' => '(- 4:00 hours) &#58; '.iz_longdatehours($servertime-14400),
      '-3' => '(- 3:00 hours) &#58; '.iz_longdatehours($servertime-10800),
      '-2' => '(- 2:00 hours) &#58; '.iz_longdatehours($servertime-7200),
      '-1' => '(- 1:00 hours) &#58; '.iz_longdatehours($servertime-3600),
      '0' => '(+ 0:00 hours) &#58; '.iz_longdatehours($servertime),
      '1' => '(+ 1:00 hours) &#58; '.iz_longdatehours($servertime+3600),
      '2' => '(+ 2:00 hours) &#58; '.iz_longdatehours($servertime+7200),
      '3' => '(+ 3:00 hours) &#58; '.iz_longdatehours($servertime+10800),
      '4' => '(+ 4:00 hours) &#58; '.iz_longdatehours($servertime+14400),
      '5' => '(+ 5:00 hours) &#58; '.iz_longdatehours($servertime+18000),
      '6' => '(+ 6:00 hours) &#58; '.iz_longdatehours($servertime+21600),
      '7' => '(+ 7:00 hours) &#58; '.iz_longdatehours($servertime+25200),
      '8' => '(+ 8:00 hours) &#58; '.iz_longdatehours($servertime+28800),
      '9' => '(+ 9:00 hours) &#58; '.iz_longdatehours($servertime+32400),
      '10' => '(+ 10:00 hours) &#58; '.iz_longdatehours($servertime+36000),
      '11' => '(+ 11:00 hours) &#58; '.iz_longdatehours($servertime+39600),
      '12' => '(+ 12:00 hours) &#58; '.iz_longdatehours($servertime+43200));        
                                  foreach($timezones as $offset => $name) {
                                        echo '<option value="'.$offset.'"';
                                        if($offset == $_SESSION['IZ_TIMEOFFSET']) {
                                          echo '  selected="selected"';
                                        }
                                        echo'>'.$name.'</option>'."\n";
                                  }
                                  ?>
    </select><br />
          <label><?php echo ADM_CURSERVERTIME; ?>&#58;</label>
          <?php echo iz_longdatehours(mktime()); ?>
          <br />
          
          <label><?php echo ADM_CURLOCALTIME; ?>&#58;</label>
    <?php echo iz_longdatehours($curtime); ?>
    <br />
    <p style="margin-left: 210px;"><?php echo ADM_TIMEOFFSETDESC; ?></p>*/?>
      <input type="hidden" name="setadmin" value="Save" /><input type="hidden" name="page" value="local" /><input type="hidden" name="act" value="admin" /><input type="hidden" name="from" value="act-admin.page-local" />
      <div class="actions"><input type="submit" value="<?php echo STR_SAVE; ?>" name="savebutton" class="nicebutton"></div>
    </div>
      </form>
  <?php } elseif($page == 'calsetup') {
    $opt_flags = $_SESSION['IZ_OPT'];
    $nv_flags = $_SESSION['IZ_NV'];
    ?>
      <div class="containerbox">
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin" onsubmit="return validate_admin();">
      
        <div class="containertitle"><?php echo ADM_CALSETUP; ?></div>
        <fieldset>
          <legend><?php echo ADM_GENSETUP; ?></legend>
          <table class="fieldstable">
          <tr><td class="parameter">
            <label><?php echo ADM_CALNAME; ?>&#58;<br /><small><?php echo ADM_CALNAMEDESC; ?></small></label>
          </td><td class="setting">
            <input type="text" name="calendarname" id="calendarname" size="40" value="<?php echo $_SESSION['IZ_CALNAME']; ?>" />
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo ADM_CALURL; ?>&#58;<br /><small><?php echo ADM_CALURLDESC; ?></small></label>
          </td><td class="setting">
            <input type="text" id="calurl" name="calurl" size="40" value="<?php if($_SESSION['IZ_CALURL'] == 1) {
                         $parts = explode("?",$_SERVER['HTTP_REFERER']);
                         echo substr($parts[0],0,strlen($parts[0])-9); } else { echo $_SESSION['IZ_CALURL']; } ?>" />
            <div class="errornomargin" id="error_calurl">&nbsp;</div>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo ADM_REWRITE; ?>&#58;<br /><small><?php echo ADM_REWRITEDESC; ?></small></label>
          </td><td class="setting">
            <div class="checks">
                <input type="radio" value="0" name="rewrite" id="rewriteoff"<?php if($_SESSION['IZ_REWRITE'] == '0') {echo ' checked="checked"';} ?> />
                <label for="rewriteoff"><?php echo STR_DISABLED; ?></label>
                
                <input type="radio" value="apache" name="rewrite" id="rewriteapache"<?php if($_SESSION['IZ_REWRITE'] == 'apache') {echo ' checked="checked"';} ?> />
                <label for="rewriteapache">Apache&#58; <?php echo ADM_REWRITEAPACHE; ?></label>
                
                <input type="radio" value="apache" name="rewrite" id="rewriteisapi"<?php if($_SESSION['IZ_REWRITE'] == 'isapi') {echo ' checked="checked"';} ?> />
                <label for="rewriteisapi">IIS&#58; <?php echo ADM_REWRITEIIS; ?></label>
            </div>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo ADM_REPLACELOGO; ?>&#58;<br /><small><?php echo ADM_REPLACELOGODESC; ?></small></label>
          </td><td class="setting">
            <input type="checkbox" id="replacelogo" name="replacelogo" value="1"<?php if($_SESSION['IZ_REPLACELOGO']) { echo ' checked="checked"'; } ?> />
            <label for="replacelogo"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo ADM_DEFAULTVIEW; ?>&#58;</label>
          </td><td class="setting">
            <select name="defaultview" id="defaultview" size="1">
              <option value="day"<?php if($_SESSION['IZ_DEFAULTVIEW'] == 'day') { echo ' selected="selected"'; } echo '>',STR_DAY; ?></option>
              <option value="week"<?php if($_SESSION['IZ_DEFAULTVIEW'] == 'week') { echo ' selected="selected"'; } echo '>',STR_WEEK; ?></option>
              <option value="month"<?php if($_SESSION['IZ_DEFAULTVIEW'] == 'month') { echo ' selected="selected"'; } echo '>',STR_MONTH; ?></option>
              <option value="extmonth"<?php if($_SESSION['IZ_DEFAULTVIEW'] == 'extmonth') { echo ' selected="selected"'; } echo '>',STR_EXTMONTH; ?></option>
              <option value="year"<?php if($_SESSION['IZ_DEFAULTVIEW'] == 'year') { echo ' selected="selected"'; } echo '>',STR_YEAR; ?></option>
            </select>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo ADM_DAYSIZE; ?>&#58;<br /><small><?php echo ADM_DAYSIZEDESC; ?></small></label>
          </td><td class="setting">
           <div class="checks">
            <input type="radio" value="small" name="monthviewdaysize" id="smallday"<?php if($_SESSION['IZ_MVIEWDAYSIZE'] == 'small') {echo ' checked="checked"';} ?> />
            <label for="smallday"><?php echo STR_SMALL; ?></label>
            
            <input type="radio" value="large" name="monthviewdaysize" id="largeday"<?php if($_SESSION['IZ_MVIEWDAYSIZE'] == 'large') {echo ' checked="checked"';} ?> />
            <label for="largeday"><?php echo STR_LARGE; ?></label>
           </div>
          </td></tr>
  
          <tr><td class="parameter">
            <label for="firstday"><?php echo ADM_FIRSTDAY; ?>&#58;</label>
          </td><td class="setting">
              <select name="firstday" size="1" id="firstday"><?php echo '
                <option value="0"',($_SESSION['IZ_FIRSTDAY'] == 0 ? ' selected="selected"' : ''),'>',$daynames[0],'</option>
                <option value="1"',($_SESSION['IZ_FIRSTDAY'] == 1 ? ' selected="selected"' : ''),'>',$daynames[1],'</option>
                <option value="2"',($_SESSION['IZ_FIRSTDAY'] == 2 ? ' selected="selected"' : ''),'>',$daynames[2],'</option>
                <option value="3"',($_SESSION['IZ_FIRSTDAY'] == 3 ? ' selected="selected"' : ''),'>',$daynames[3],'</option>
                <option value="4"',($_SESSION['IZ_FIRSTDAY'] == 4 ? ' selected="selected"' : ''),'>',$daynames[4],'</option>
                <option value="5"',($_SESSION['IZ_FIRSTDAY'] == 5 ? ' selected="selected"' : ''),'>',$daynames[5],'</option>
                <option value="6"',($_SESSION['IZ_FIRSTDAY'] == 6 ? ' selected="selected"' : ''),'>',$daynames[6],'</option>
              '; ?></select>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo ADM_DEFNUMRECS; ?>&#58;<br /><small><?php echo ADM_DEFNUMRECSDESC; ?></small></label>
          </td><td class="setting">
            <input type="text" name="defnumrecs" id="defnumrecs" size="2" value="<?php echo $_SESSION['IZ_DEFNUMRECS']; ?>" />
          </td></tr>
          
  
            
          <tr><td class="parameter">
            <label><?php echo STR_TODO; ?>&#58;</label>
          </td><td class="setting">
            <div class="checks">
              <input type="checkbox" name="allowtodo" id="allowtodo" class="nomargin" value="1"<?php if(($opt_flags & OPT_TODO) != 0) {echo ' checked="checked"'; }?> />
              <label for="allowtodo"><?php echo ADM_ALLOWTODO; ?></label>
            </div>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_GOTODAY; ?>&#58;<br /><small><?php echo ADM_GOTODESC; ?></small></label>
          </td><td class="setting">
            <div class="checks">
              <input type="checkbox" name="allowgoto" id="allowgoto" class="nomargin" value="1"<?php if(($opt_flags & OPT_GOTO) != 0) {echo ' checked="checked"'; }?> />
              <label for="allowgoto"><?php echo STR_ENABLED; ?></label>
            </div>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_FILTERS; ?>&#58;<br /><small><?php echo ADM_FILTERSDESC; ?></small></label>
          </td><td class="setting">
            <div class="checks">
              <input type="checkbox" name="allowfilters" id="allowfilters" class="nomargin" value="1"<?php if(($opt_flags & OPT_FILTERS) != 0) {echo ' checked="checked"'; }?> />
              <label for="allowfilters"><?php echo STR_ENABLED; ?></label>
            </div>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo STR_COMMENTS; ?>&#58;</label>
          </td><td class="setting">
            <div class="checks">
                <input type="radio" value="1" name="allowcomments" id="commentson"<?php if($_SESSION['IZ_ALLOWCOMMENTS'] == '1') {echo ' checked="checked"';} ?> />
                <label for="commentson"><?php echo ADM_ON; ?></label>
                
                <input type="radio" value="0" name="allowcomments" id="commentsoff"<?php if($_SESSION['IZ_ALLOWCOMMENTS'] == '0') {echo ' checked="checked"';} ?> />
                <label for="commentsoff"><?php echo ADM_OFF; ?></label>
                
                <input type="radio" value="author" name="allowcomments" id="commentsauthor"<?php if($_SESSION['IZ_ALLOWCOMMENTS'] == 'author') {echo ' checked="checked"';} ?> />
                <label for="commentsauthor"><?php echo ADM_USERCONTROLLED; ?></label>
            </div>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo ADM_ITEMCOLORS; ?>&#58;<br /><small><?php echo ADM_ITEMCOLORSDESC; ?></small></label>
            <?php /* Modes are (C)ategory, (A)uthor and (T)heme */ ?>
          </td><td class="setting">
            <div class="checks">
                <input type="radio" value="c" name="itemcolors" id="colormodecat"<?php if($_SESSION['IZ_ITEMCOLORS'] == 'c') {echo ' checked="checked"';} ?> />
                <label for="colormodecat"><?php echo ADM_COLORCAT; ?></label>
                
                <input type="radio" value="a" name="itemcolors" id="colormodeauthor"<?php if($_SESSION['IZ_ITEMCOLORS'] == 'a') {echo ' checked="checked"';} ?> />
                <label for="colormodeauthor"><?php echo ADM_COLORAUTHOR; ?></label>
  
                <input type="radio" value="t" name="itemcolors" id="colormodetheme"<?php if($_SESSION['IZ_ITEMCOLORS'] == 't') {echo ' checked="checked"';} ?> />
                <label for="colormodetheme"><?php echo ADM_COLORTHEMEDEFAULT; ?></label>
            </div>
          </td></tr>
          </table>
        </fieldset>
        
        <br />
        
        <fieldset>
          <legend><?php echo STR_INVITES; ?></legend>
                
          <label><?php echo STR_INVITES; ?>&#58;<br /><small><?php echo ADM_INVMODEDESC; ?></small></label>
          <div class="checks">
              <input type="radio" value="php" name="IZ_INVITEMODE" class="nomargin" id="phpinv"<?php if($_SESSION['IZ_INVITEMODE'] == 'php') {echo ' checked="checked"';} ?> /><label for="phpinv" class="plain">PHP</label>
              <input type="radio" value="gmail" name="IZ_INVITEMODE" class="nomargin" id="gmailinv"<?php if($_SESSION['IZ_INVITEMODE'] == 'gmail') {echo ' checked="checked"';} ?> /><label for="gmailinv" class="plain">GMail</label>
          </div>
          <br />
      
          <label for="IZ_GMAIL_ACC"><?php echo ADM_GMAIL_ACC; ?>&#58;</label>
          <input type="text" name="IZ_GMAIL_ACC" id="IZ_GMAIL_ACC" size="30" value="<?php echo $_SESSION['IZ_GMAIL_ACC']; ?>" class="inline" /><br />
          
          <label for="IZ_GMAIL_PWD"><?php echo ADM_GMAIL_PWD; ?>&#58;</label>
          <input type="password" name="IZ_GMAIL_PWD" id="IZ_GMAIL_PWD" size="30" value="<?php echo $_SESSION['IZ_GMAIL_PWD']; ?>" class="inline" /><br />
          <div class="errornomargin" id="error_invites" style="margin-left: 100px;">&nbsp;</div>
        
        </fieldset>
        
        <br />
        
        <fieldset>
          <legend><?php echo ADM_NAVBAR; ?></legend>
                
          <em><?php echo ADM_NAVBARDESC; ?></em><br /><br />
          <table class="fieldstable">
                                  
          <tr><td class="parameter">
            <label><?php echo STR_SETTINGS; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowcust" id="allowcust" class="nomargin" value="1"<?php if(($nv_flags & NV_SETTINGS) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowcust"><?php echo STR_ENABLED; ?></label>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo STR_EVMGR; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowevmgr" id="allowevmgr" class="nomargin" value="1"<?php if(($nv_flags & NV_EVMGR) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowevmgr"><?php echo STR_ENABLED; ?></label>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo STR_RSSFEED; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowrss" id="allowrss" class="nomargin" value="1"<?php if(($nv_flags & NV_RSS) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowrss"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label>iCal&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowical" id="allowical" class="nomargin" value="1"<?php if(($nv_flags & NV_ICAL) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowical"><?php echo STR_ENABLED; ?></label>
          </td></tr>
     
          <tr><td class="parameter">
            <label><?php echo STR_SEARCH; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowsearch" id="allowsearch" class="nomargin" value="1"<?php if(($nv_flags & NV_SEARCH) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowsearch"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_REPORTS; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowreports" id="allowreports" class="nomargin" value="1"<?php if(($nv_flags & NV_REPORTS) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowreports"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_PRINT; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowprint" id="allowprint" class="nomargin" value="1"<?php if(($nv_flags & NV_PRINT) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowprint"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_HELP; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowhelp" id="allowhelp" class="nomargin" value="1"<?php if(($nv_flags & NV_HELP) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowhelp"><?php echo STR_ENABLED; ?></label>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo STR_DAY; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowviewday" id="allowviewday" class="nomargin" value="1"<?php if(($nv_flags & NV_DAY) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowviewday"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_WEEK; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowviewweek" id="allowviewweek" class="nomargin" value="1"<?php if(($nv_flags & NV_WEEK) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowviewweek"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_MONTH; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowviewmonth" id="allowviewmonth" class="nomargin" value="1"<?php if(($nv_flags & NV_MONTH) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowviewmonth"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_EXTMONTH; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowviewextmonth" id="allowviewextmonth" class="nomargin" value="1"<?php if(($nv_flags & NV_EXTMONTH) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowviewextmonth"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_YEAR; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowviewyear" id="allowviewyear" class="nomargin" value="1"<?php if(($nv_flags & NV_YEAR) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowviewyear"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
      </table>
        
        </fieldset>
        
        <br />
        
        <fieldset>
                <legend><?php echo ADM_EVENTFIELDS; ?></legend>
                
          <em><?php echo ADM_EVENTFIELDSDESC; ?></em><br /><br />
          <table class="fieldstable">
                                  
          <tr><td class="parameter">
            <label><?php echo ADM_ENDDATE; ?>&#58;<br />
            <small><?php echo ADM_ENDDATEDESC?></small></label>
          </td><td class="setting">
            <input type="checkbox" name="allowenddate" id="allowenddate" value="1"<?php if(($opt_flags & OPT_ENDDATE) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowenddate"><?php echo STR_ENABLED; ?></label>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo STR_ATTENDEES; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowattendees" id="allowattendees" value="1"<?php if(($opt_flags & OPT_ATTENDEES) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowattendees"><?php echo STR_ENABLED; ?></label>
          </td></tr>
  
          <tr><td class="parameter">
            <label><?php echo STR_VENUE; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowvenue" id="allowvenue" value="1"<?php if(($opt_flags & OPT_VENUE) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowvenue"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_LINKGOOGLE; ?>&#58;<br /></label>
          </td><td class="setting">
            <input type="checkbox" name="allowgoogle" id="allowgoogle" value="1"<?php if(($opt_flags & OPT_GOOGLE) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowgoogle"><?php echo STR_ENABLED; ?></label><br /><br />
            <input type="checkbox" name="opengooglenewwindow" id="opengooglenewwindow" value="1"<?php if(($opt_flags & OPT_GOOGLENEWWINDOW) != 0) {echo ' checked="checked"'; } if(($opt_flags & OPT_GOOGLE) == 0) { echo ' disabled="disabled"'; } ?> />
            <label for="opengooglenewwindow"><?php echo STR_OPENGOOGLENEWWINDOW; ?></label>
            <?php
              $onload .= 'listen(\'click\',\'allowgoogle\',togglegooglecheck);'."\n";
            ?>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_CATEGORY; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowcat" id="allowcat" value="1"<?php if(($opt_flags & OPT_CATEGORY) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowcat"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_ICON; ?>&#58;<br /></label>
          </td><td class="setting">
            <input type="checkbox" name="allowicon" id="allowicon" value="1"<?php if(($opt_flags & OPT_ICON) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowicon"><?php echo STR_ENABLED; ?></label>
          </td></tr>
          
          <tr><td class="parameter">
            <label><?php echo STR_RECURRENCE; ?>&#58;</label>
          </td><td class="setting">
            <input type="checkbox" name="allowrecurrence" id="allowrecurrence" value="1"<?php if(($opt_flags & OPT_RECURRENCE) != 0) {echo ' checked="checked"'; }?> />
            <label for="allowrecurrence"><?php echo STR_ENABLED; ?></label>
          </td></tr>
  
      </table>
                   <br />
  
            <fieldset>
                  <legend><?php echo ADM_CUSTFIELDS; ?></legend>
                  
                <em><?php echo ADM_CUSTFIELDSDESC; ?></em><br /><br />
      
                  <fieldset>
                  <legend><?php echo ADM_CUSTFIELD; ?> 1</legend>
                          <label for="cust1on" class="compact"><?php echo STR_ENABLED; ?>&#58;</label>
                          <input type="checkbox" name="cust1on" id="cust1on" onchange="setdisabled();" value="on"<?php if($_SESSION['cust1'] != 'none') {echo ' checked="checked"'; }?> /><br />
                          <label for="cust1name" class="compact"><?php echo STR_NAME; ?>&#58;</label>
                          <input type="text" name="cust1" id="cust1name" size="20" <?php if($_SESSION['cust1'] != 'none') {echo 'value="'.$_SESSION['cust1'].'"'; }?> class="inline" /><br />
                          <div class="errornomargin" id="error_cust1" style="margin-left: 100px;">&nbsp;</div>
                  </fieldset>
      
                  <br />
      
                  <fieldset>
                  <legend><?php echo ADM_CUSTFIELD; ?> 2</legend>
                          <label for="cust2on" class="compact"><?php echo STR_ENABLED; ?>&#58;</label>
                          <input type="checkbox" name="cust2on" id="cust2on" onchange="setdisabled();" value="on"<?php if($_SESSION['cust2'] != 'none') {echo ' checked="checked"'; }?> /><br />
                          <label for="cust2name" class="compact"><?php echo STR_NAME; ?>&#58;</label>
                          <input type="text" name="cust2" id="cust2name" size="20" <?php if($_SESSION['cust2'] != 'none') {echo 'value="'.$_SESSION['cust2'].'"'; }?> class="inline" /><br />
                          <div class="errornomargin" id="error_cust2" style="margin-left: 100px;">&nbsp;</div>
                  </fieldset>
      
                  <br />
      
                  <fieldset>
                  <legend><?php echo ADM_CUSTFIELD; ?> 3</legend>
                          <label for="cust3on" class="compact"><?php echo STR_ENABLED; ?>&#58;</label>
                          <input type="checkbox" name="cust3on" id="cust3on" onchange="setdisabled();" value="on"<?php if($_SESSION['cust3'] != 'none') {echo ' checked="checked"'; }?> /><br />
                          <label for="cust3name" class="compact"><?php echo STR_NAME; ?>&#58;</label>
                          <input type="text" name="cust3" id="cust3name" size="20" <?php if($_SESSION['cust3'] != 'none') {echo 'value="'.$_SESSION['cust3'].'"'; }?> class="inline" /><br />
                          <div class="errornomargin" id="error_cust3" style="margin-left: 100px;">&nbsp;</div>
                  </fieldset>
            </fieldset>
        </fieldset>
        <br />
  
        <input type="hidden" name="setadmin" value="Save" />
        <input type="hidden" name="page" value="calsetup" />
        <input type="hidden" name="act" value="admin" />
        <input type="hidden" name="from" value="act-admin.page-calsetup" />
        <div class="actions"><input type="submit" value="<?php echo STR_SAVE; ?>" name="savebutton" class="nicebutton" /></div>
        </form>
        </div>
  <?php } elseif($page == 'users') { ?>
      <div class="containerbox" id="adduser">
      <div class="containertitle"><?php echo ADM_USERS; ?></div>
      
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php">
            <fieldset>
              <legend><?php echo ADM_ALLOWREG; ?></legend>
                  
              <table class="fieldstable">    
                <tr><td class="parameter">
                  <label><?php echo ADM_ALLOWREG; ?>&#58;<br />
                  <small><?php echo ADM_ALLOWREGDESC?></small></label>
                </td><td class="setting">
                  <input type="checkbox" name="allowreg" id="allowreg" value="1"<?php if(($_SESSION['IZ_OPT'] & OPT_REG) != 0) {echo ' checked="checked"'; }?> />
                  <label for="allowreg"><?php echo STR_ENABLED; ?></label>
                </td></tr>
        
                <tr><td class="parameter">
                  <label><?php echo ADM_DEFAULTGROUP; ?>&#58;<br />
                  <small><?php echo ADM_DEFAULTGROUPDESC?></small></label>
                </td><td class="setting">
                  <select name="defaultgroup" id="defaultgroup" size="1" tabindex="5">
                  <?php $tabindex = 6; get_groups('dropdown',1,$_SESSION['IZ_DEFAULTGROUP']); ?>
                  </select>
                </td></tr>
              </table>
              <input type="hidden" name="setadmin" value="Save" />
              <input type="hidden" name="page" value="users" />
              <input type="hidden" name="act" value="admin" />
              <input type="hidden" name="saveregsettings" value="saveregsettings" />
              <input type="hidden" name="from" value="act-admin.page-users" />
              <div class="actions">
                <input type="submit" value="<?php echo STR_SAVE; ?>" name="go" class="nicebutton" tabindex="<?php echo $tabindex ?>" />
              </div>
            </fieldset>
          <br />
        </form>
          
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin" onsubmit="return validate_admin();">
              <fieldset>
                  <legend><?php echo ADM_ADDUSER; ?></legend>
                  <table class="fieldstable">
                                          
                  <tr><td class="parameter">
                    <label for="username"><?php echo STR_USERNAME; ?>&#58;</label>
                  </td><td class="setting">
                    <input type="text" name="username" id="username" class="inline" size="30" tabindex="1" />
                  </td></tr>
                  
                  <tr><td class="parameter">
                    <label for="password"><?php echo STR_PASSWORD; ?>&#58;</label>
                  </td><td class="setting">
                    <input type="password" name="pass" id="pass" class="inline" size="30" tabindex="2" />
                  </td></tr>
                  
                  <tr><td class="parameter">
                    <label for="confpass"><?php echo STR_CONFIRMPASS; ?>&#58;</label>
                  </td><td class="setting">
                    <input type="password" name="confpass" id="confpass" class="inline" size="30" tabindex="3" />
                  </td></tr>
  
                  <?php if($_SESSION['IZ_ITEMCOLORS'] == 'a') { ?>
                  <tr><td class="parameter">
                    <label for="colour"><?php echo STR_COLOUR; ?>&#58;<br /><br />
                    <small><?php echo STR_COLOURDESC ?></small></label>
                  </td><td class="setting">
                  <div class="inlinecolourpick"><input type="text" name="colour" id="colour" class="inline colourinput" size="30" tabindex="4" />
                  <a id="newusercolourpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a></div>
                  </td></tr>
                  <?php $jsfoot = 'new Control.ColorPicker("colour", { "swatch" : "newusercolourpicker" });'."\n";
                  } ?>
                  
                  <tr><td class="parameter">
                    <label for="group"><?php echo ADM_GROUP; ?>&#58;</label>
                  </td><td class="setting">
                    <select name="group" id="group" size="1" tabindex="5">
                    <?php $tabindex = 6; get_groups('dropdown'); ?>
                    </select>
                  </td></tr>
                  </table>
                  <input type="hidden" name="page" value="users" />
                  <input type="hidden" name="act" value="admin" />
                  <input type="hidden" name="adduser" value="adduser" />
                  <input type="hidden" name="from" value="act-admin.page-users" />
                  <input type="hidden" name="setadmin" value="Save" />
                  <div class="actions">
                    <input type="submit" value="<?php echo ADM_ADDUSER; ?>" name="setadmin" class="nicebutton" tabindex="<?php echo $tabindex ?>" />
                  </div>
              </fieldset>
          </form>
                
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php">
              <fieldset>
                  <legend><?php echo ADM_MANAGEUSERS; ?></legend>
                  <?php if($_SESSION['IZ_ITEMCOLORS'] != 'a') {
                      echo STR_COLORUSERSDISABLED; 
                    } ?>
                  <table width="100%" class="admintable">
                    <tr class="evenrow">
                      <td class="titleback2" width="250"><?php echo STR_NAME; ?></td>
                      <td class="titleback2"><?php echo ADM_GROUP; ?></td>
                      <?php if($_SESSION['IZ_ITEMCOLORS'] == 'a') {
                        echo '<td class="titleback2" colspan="2">'.STR_COLOUR.'</td>';
                      } ?>
                    </tr>
                    <?php get_users(); ?>
                    <tr><td colspan="7">
                       <input type="hidden" name="setadmin" value="setadmin" />
                       <input type="hidden" name="page" value="users" />
                       <input type="hidden" name="act" value="admin" />
                       <input type="hidden" name="saveusers" value="saveusers" />
                       <input type="hidden" name="from" value="act-admin.page-users" />
                       <input type="submit" value="<?php echo STR_SAVE; ?>" tabindex="<?php echo $tabindex; $tabindex++; ?>" name="setadmin" class="nicebutton" style="float: right;" />
                    </td></tr>
                  </table>
              </fieldset>
          </form>
      </div>
  
      <br />
  
      <div class="containerbox" id="addgroup" style="width: auto;">
      <div class="containertitle"><?php echo ADM_GROUPS; ?></div>
          
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php">
              <fieldset>
                  <legend><?php echo ADM_ADDGROUP; ?></legend>
                  <label for="groupname"><?php echo ADM_GROUPNAME; ?>&#58;</label>
                  <input type="text" name="groupname" id="groupname" class="inline" size="30" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><br />
                  
                  <label><?php echo ADM_PERMISSIONS; ?>&#58;</label>
                  <div class="checks">
                      <input type="checkbox" name="view" id="view" value="1" class="nomargin" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><label for="view"><?php echo ADM_VIEWCAL; ?></label>
                  </div>
                  <div class="checks">
                      <input type="checkbox" name="cpanel" id="cpanel" value="1" class="nomargin" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><label for="cpanel"><?php echo ADM_VIEWCPANEL; ?></label>
                  </div>
                  <div class="checks">
                      <input type="checkbox" name="customise" id="customise" value="1" class="nomargin" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><label for="customise"><?php echo STR_CUSTOMISE; ?></label>
                  </div>
                  <div class="checks">
                      <input type="checkbox" name="comment" id="comment" value="1" class="nomargin" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><label for="comment"><?php echo STR_COMMENT; ?></label>
                  </div>
                  
                  <label><?php echo ADM_EDITEVENTS; ?>&#58;</label>
                  <div class="checks">
                      <input type="radio" name="edit" id="editall" value="2" class="nomargin" tabindex="<?php echo $tabindex; ?>" /><label for="editall"><?php echo STR_ALL; ?></label>
                  </div>
                  <div class="checks">
                      <input type="radio" name="edit" id="editown" value="1" class="nomargin" tabindex="<?php echo $tabindex; ?>" checked="checked" /><label for="editown"><?php echo ADM_OWN; ?></label>
                  </div>
                  <div class="checks">
                      <input type="radio" name="edit" id="editnone" value="0" class="nomargin" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><label for="editnone"><?php echo STR_NONE; ?></label>
                  </div>
                  
                  <label><?php echo ADM_DELEVENTS; ?>&#58;</label>
                  <div class="checks">
                      <input type="radio" name="delete" id="delall" value="2" class="nomargin" tabindex="<?php echo $tabindex; ?>" /><label for="delall"><?php echo STR_ALL; ?></label>
                  </div>
                  <div class="checks">
                      <input type="radio" name="delete" id="delown" value="1" class="nomargin" tabindex="<?php echo $tabindex; ?>" checked="checked" /><label for="delown"><?php echo ADM_OWN; ?></label>
                  </div>
                  <div class="checks">
                      <input type="radio" name="delete" id="delnone" value="0" class="nomargin" tabindex="<?php echo $tabindex; $tabindex++; ?>" /><label for="delnone"><?php echo STR_NONE; ?></label>
                  </div>
  
                  <input type="hidden" name="page" value="users" />
                  <input type="hidden" name="act" value="admin" />
                  <input type="hidden" name="addgroup" value="addgroup" />
                  <input type="hidden" name="from" value="act-admin.page-users" />
                  <div class="actions">
                    <input type="submit" value="<?php echo ADM_ADDGROUP; ?>" name="setadmin" class="nicebutton" tabindex="<?php echo $tabindex; $tabindex++; ?>" />
                  </div>
              </fieldset>
          </form>
  
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php">
              <fieldset>
              <legend><?php echo ADM_GROUPPERMS; ?></legend>
                  <table class="admintable">
                    <tr class="evenrow">
                      <td class="titleback2" width="15%"><?php echo STR_NAME; ?></td>
                      <td class="titleback2" width="15%"><?php echo ADM_VIEWCAL; ?></td>
                      <td class="titleback2" width="15%"><?php echo ADM_EDITEVENTS; ?></td>
                      <td class="titleback2" width="15%"><?php echo ADM_DELEVENTS; ?></td>
                      <td class="titleback2" width="15%"><?php echo ADM_VIEWCPANEL; ?></td>
                      <td class="titleback2" width="15%"><?php echo STR_CUSTOMISE; ?></td>
                      <td class="titleback2" width="15%"><?php echo STR_COMMENT; ?></td>
                    </tr>
                    <?php get_groups('adminlist',$tabindex); ?>
                    <tr><td colspan="8">
                       <input type="hidden" name="setadmin" value="Backup" />
                       <input type="hidden" name="page" value="users" />
                       <input type="hidden" name="act" value="admin" />
                       <input type="hidden" name="savegroups" value="savegroups" />
                       <input type="hidden" name="from" value="act-admin.page-users" />
                       <input type="submit" value="<?php echo STR_SAVE; ?>" name="setadmin" class="nicebutton" style="float: right;" tabindex="<?php echo $tabindex; $tabindex++; ?>" />
                    </td></tr>
                  </table>
              </fieldset>
          </form>
      </div>
          
  <?php } elseif($page == 'themes') { ?>
      <div class="containerbox">
      <div class="containertitle"><?php echo ADM_THEMES; ?></div>
                  <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin" onsubmit="return validate_admin();">    
      
      <fieldset>
      <legend><?php echo ADM_SELECTTHEME; ?></legend>
      <?php getthemes('admin'); ?>
      </fieldset>
      
      <br />
  
      <fieldset>
      <legend><?php echo ADM_CUSTOMISETHEME; ?></legend>
  
          <em><?php echo ADM_CUSTTHEMEDESC; ?></em>
          <br /><br />
          <table id="themestable" class="fieldstable">
              <tr><td>
                <label for="pagebg"><?php echo ADM_PAGEBG; ?>&#58;</label>
              </td><td>
                &#35;<input type="text" name="pagebg" size="7" class="inline colourinput" id="pagebg" value="<?php echo $_SESSION['cust_pagebg']; ?>" />
              </td><td>
                <a id="pagebgpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
              </td></tr>
  
              <tr><td>
                <label for="calbg"><?php echo ADM_CALBG; ?>&#58;<br /><small><?php echo ADM_CALBGDESC; ?></small></label>
              </td><td>
                &#35;<input type="text" name="calbg" size="7" class="inline colourinput" id="calbg" value="<?php echo $_SESSION['cust_calbg']; ?>" />
              </td><td>
                <a id="calbgpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
              </td></tr>
  
              <tr><td>
                <label for="calwrappertext"><?php echo ADM_CALWRAPPERTEXT; ?>&#58;<br /><small><?php echo ADM_CALWRAPPERTEXTDESC; ?></small></label>
              </td><td>
                &#35;<input type="text" name="calwrappertext" size="7" class="inline colourinput" id="calwrappertext" value="<?php echo $_SESSION['cust_calwrappertext']; ?>" />
              </td><td>
                <a id="calwrappertextpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
              </td></tr>
              
              <tr><td>
                <label for="boxbg"><?php echo ADM_BOXBG; ?>&#58;<br /><small><?php echo ADM_BOXBGDESC; ?></small></label>
              </td><td>
                &#35;<input type="text" name="boxbg" size="7" class="inline colourinput" id="boxbg" value="<?php echo $_SESSION['cust_boxbg']; ?>" />
              </td><td>
                <a id="boxbgpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
              </td></tr>
  
              <tr><td>
                <label for="boxtext"><?php echo ADM_BOXTEXT; ?>&#58;<br /><small><?php echo ADM_BOXTEXTDESC; ?></small></label>
              </td><td>
                &#35;<input type="text" name="boxtext" size="7" class="inline colourinput" id="boxtext" value="<?php echo $_SESSION['cust_boxtext']; ?>" />
              </td><td>
                <a id="boxtextpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
              </td></tr>
  
              <tr><td>
                <label for="occbg"><?php echo ADM_OCCBG; ?>&#58;</label>
              </td><td>
                &#35;<input type="text" name="occbg" size="7" class="inline colourinput" id="occbg" value="<?php echo $_SESSION['cust_occbg']; ?>" />
              </td><td>
                <a id="occbgpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
              </td></tr>
  
              <tr><td>
                <label for="occtext"><?php echo ADM_OCCTEXT; ?>&#58;</label>
              </td><td>
                &#35;<input type="text" name="occtext" size="7" class="inline colourinput" id="occtext" value="<?php echo $_SESSION['cust_occtext']; ?>" />
              </td><td>
                <a id="occtextpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
  
             <tr><td>
               <label for="blankbg"><?php echo ADM_BLANKBG; ?>&#58;</label>
             </td><td>
               &#35;<input type="text" name="blankbg" size="7" class="inline colourinput" id="blankbg" value="<?php echo $_SESSION['cust_blankbg']; ?>" />
             </td><td>
               <a id="blankbgpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
  
             <tr><td>
               <label for="blanktext"><?php echo ADM_BLANKTEXT; ?>&#58;</label>
             </td><td>
               &#35;<input type="text" name="blanktext" size="7" class="inline colourinput" id="blanktext" value="<?php echo $_SESSION['cust_blanktext']; ?>" />
             </td><td>
               <a id="blanktextpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
  
             <tr><td>
               <label for="todaybg"><?php echo ADM_TODAYBG; ?>&#58;</label>
             </td><td>
               &#35;<input type="text" name="todaybg" size="7" class="inline colourinput" id="todaybg" value="<?php echo $_SESSION['cust_todaybg']; ?>" />
             </td><td>
               <a id="todaybgpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
  
             <tr><td>
               <label for="todaytext"><?php echo ADM_TODAYTEXT; ?>&#58;</label>
             </td><td>
               &#35;<input type="text" name="todaytext" size="7" class="inline colourinput" id="todaytext" value="<?php echo $_SESSION['cust_todaytext']; ?>" />
             </td><td>
               <a id="todaytextpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
  
             <tr><td>
               <label for="fillerdays"><?php echo ADM_FILLERDAYS; ?>&#58;<br /><small><?php echo ADM_FILLERDAYSDESC; ?></small></label>
             </td><td>
               &#35;<input type="text" name="fillerdays" size="7" class="inline colourinput" id="fillerdays" value="<?php echo $_SESSION['cust_fillerdays']; ?>" />
             </td><td>
               <a id="fillerdayspicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
  
             <tr><td>
               <label for="othertext"><?php echo ADM_OTHERTEXT; ?>&#58;<br /><small><?php echo ADM_OTHERTEXTDESC; ?></small></label>
             </td><td>
               &#35;<input type="text" name="othertext" size="7" class="inline colourinput" id="othertext" value="<?php echo $_SESSION['cust_othertext']; ?>" />
             </td><td>
               <a id="othertextpicker" class="colourpicker" title="Pick">&nbsp;&nbsp;</a>
             </td></tr>
             </table>
      </fieldset>
                  <input type="hidden" name="setadmin" value="Save" />
                  <input type="hidden" name="page" value="themes" />
                  <input type="hidden" name="act" value="admin" />
                  <input type="hidden" name="custtheme" value="custtheme" />
                  <input type="hidden" name="from" value="act-admin.page-themes" />
      <div class="actions"><input type="submit" value="<?php echo STR_SAVE; ?>" name="savebutton" class="nicebutton" /></div>
      </form>
          </div>
  <?php } elseif($page == 'backup') { ?>
      <div class="containerbox">
          <div class="containertitle"><?php echo ADM_BACKUP; ?></div>
              <fieldset>
                  <legend><?php echo ADM_ACTBACKUP; ?></legend>
                  <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin">
                  <table class="fieldstable">
              	  <tr>
              	    <td class="parameter"><label><?php echo ADM_DATAFORMAT; ?>&#58;</label></td>
              	    <td class="setting">
              	        <select name="exporttype">
              	            <option value="xml" selected="selected">XML</option>
              	        </select>
              	    </td>
              	  </tr>
              	  <tr>
              	    <td class="parameter"><?php /*echo ADM_ACTBACKUPDESC; */ ?>&nbsp;</td>
              	    <td class="setting">
              	                <input type="submit" value="<?php echo ADM_ACTBACKUP; ?>" name="backupbutton" class="nicebutton" />
              	                <input type="hidden" name="setadmin" value="Backup" /><input type="hidden" name="page" value="backup" /><input type="hidden" name="act" value="admin" />
              	                <input type="hidden" name="from" value="act-admin.page-backup" />
              	    </td>
              	
              	  </tr>
                  </table>
                  </form>
              </fieldset>
              <fieldset>
                  <legend><?php echo ADM_ACTRESTORE; ?></legend>
                  <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin">
                  <table class="fieldstable">
                    <tr>
                      <td class="parameter"><label><?php echo ADM_RESTOREDESC; ?>&#58;</label></td>
                      <td class="setting"><input type="file" name="backupfile" class="nicebutton" /></td>
                    </tr>
                    <tr>
                      <td class="parameter">&nbsp;</td>
                      <td class="setting">
                        <input type="checkbox" value="1" name="cleardb" id="cleardb" checked="checked" />
                        <label for="cleardb"><?php echo ADM_CLEARDB; ?></label>
                      </td>
                    </tr>
                    <tr>
                      <td class="parameter">&nbsp;</td>
                      <td class="setting"><input type="submit" value="<?php echo ADM_ACTRESTORE; ?>" name="restorebutton" class="nicebutton" /></td>
                    </tr>
                  </table>
                  <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
                  <input type="hidden" name="setadmin" value="Restore" />
                  <input type="hidden" name="page" value="backup" />
                  <input type="hidden" name="act" value="admin" />
                  <input type="hidden" name="from" value="act-admin.page-backup" />
                  </form>
              </fieldset>
          </div>
  <?php } elseif($page == 'system') { ?>
      <div class="containerbox">
          <div class="containertitle"><?php echo ADM_SYSTEM; ?></div>
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin" onsubmit="return validate_admin();">
          <label for="calmode"><?php echo ADM_CALMODE; ?>&#58;</label>
          <div class="checks">
              <input type="radio" value="text" id="textmode" disabled="disabled" class="nomargin" <?php if(IZ_CALMODE == 'text') { echo 'checked="checked" '; } ?>name="calmode" /><label for="textmode" class="plain"><?php echo ADM_TEXTMODE; ?></label>
              <input type="radio" value="mysql" id="mysqlmode" class="nomargin" <?php if(IZ_CALMODE == 'mysql') { echo 'checked="checked" '; } ?>name="calmode" /><label for="mysqlmode" class="plain">MySQL</label>
              <input type="radio" value="postgre" id="postgremode" class="nomargin" <?php if(IZ_CALMODE == 'postgre') { echo 'checked="checked" '; } ?>name="calmode" /><label for="postgremode" class="plain">PostgreSQL</label>
              <input type="radio" value="msq" id="msqmode" class="nomargin" <?php if(IZ_CALMODE == 'msq') { echo 'checked="checked" '; } ?>name="calmode" /><label for="msqmode" class="plain">MSSQL</label>
          </div><br />
  
          <label for="dbhost"><?php echo ADM_SQLHOST; ?>&#58;</label>
          <input type="text" id="dbhost" name="dbhost" class="inline" size="30" value="<?php echo $dbhost; ?>" /><div class="errornomargin" id="error_dbhost">&nbsp;</div><br />
  
          <label for="dbuser"><?php echo ADM_SQLUSER; ?>&#58;</label>
          <input type="text" id="dbuser" name="dbuser" class="inline" size="30" value="<?php echo $dbuser; ?>" /><div class="errornomargin" id="error_dbuser">&nbsp;</div><br />
  
          <label for="dbpass"><?php echo ADM_SQLPASS; ?>&#58;<br /><small><?php echo ADM_SQLPASSDESC; ?></small></label>
          <input type="password" id="dbpass" name="dbpass" class="inline" size="30" /><br />
  
          <label for="dbdatabase"><?php echo ADM_SQLDB; ?>&#58;</label>
          <input type="text" id="dbdatabase" name="dbdatabase" class="inline" size="30" value="<?php echo $dbdatabase; ?>" /><div class="errornomargin" id="error_dbdatabase">&nbsp;</div><br />
  
          <label><?php echo ADM_PHPVER; ?>&#58;</label>
          <p style="padding-top: 2px;"><?php echo phpversion(); ?></p><br />
  
          <label><?php echo ADM_IZVER; ?>&#58;</label><p style="padding-top: 2px;">
          <p style="padding-top: 2px; padding-left:210px"><?php echo IZ_CALVERSION; ?><br /><a href="http://www.izeit.nu/download/"><?php echo '&#40;'.ADM_IZLATESTVER.'&#41;'; ?></a></p>
                          <input type="hidden" name="page" value="system" /><input type="hidden" name="act" value="admin" /><input type="hidden" name="from" value="act-admin.page-system" />
        <div class="actions"><input type="submit" value="<?php echo STR_SAVE; ?>" name="setadmin" class="nicebutton" /></div>
      </form>
          </div>
  <?php } } elseif($_POST['setadmin'] == 'Restore') {
       $filename = $_FILES['backupfile']['tmp_name'];
       if(empty($_FILES['backupfile']['error'])) {
         $backupfile = file_get_contents($_FILES['backupfile']['tmp_name']);
         if(substr($_FILES['backupfile']['name'],-3) == 'xml') {
           $_SESSION['fevents'] = array();
           $_SESSION['ftodo'] = array();
           $_SESSION['fcats'] = array();
           $_SESSION['fsettings'] = array();
           $_SESSION['fusers'] = array();
           $_SESSION['fgroups'] = array();
           include($_SESSION['IZ_CALPATH'].'includes/xml.php');
           importXml($filename,true);
        ?>
       <div class="containerbox">
          <div class="containertitle"><?php echo ADM_ACTRESTORE; ?></div>
          <table class="backuptable">
            <tr>
              <td class="label"><?php echo ADM_BACKUPDATE; ?>&#58;</td>
              <td><?php echo $_SESSION['backupmeta']['date']; ?></td>
            </tr>
            <tr>
              <td class="label"><?php echo ADM_BACKUPSIZE; ?>&#58;</td>
              <td><?php echo $_FILES['backupfile']['size']; ?> bytes</td>
            </tr>
            <tr>
              <td class="label"><?php echo ADM_IZVER; ?>&#58;</td>
              <td><?php echo $_SESSION['backupmeta']['generator'].' '.$_SESSION['backupmeta']['izver']; ?></td>
            </tr>
            <tr>
              <td class="label"><?php echo ADM_BACKUPNUMEVENTS; ?>&#58;</td>
              <td><?php echo count($_SESSION['fevents']); ?></td>
            </tr>
            <tr>
              <td class="label"><?php echo STR_CATEGORIES; ?>&#58;</td>
              <td><?php if(sizeof($lcats) > 0) { echo implode(", ",$lcats); } else { echo 0; } ?></td>
            </tr>
            <tr>
              <td class="label"><?php echo ADM_USERS; ?>&#58;</td>
              <td><?php if(sizeof($lusers) > 0) { echo implode(", ",$lusers); } else { echo 0; } ?></td>
            </tr>
          </table>
          <form enctype="multipart/form-data" method="post" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" name="admin">
          <div id="warningbox" style="margin: 10px auto;"><?php 
            echo '<p>',ADM_RESTOREWARN,'</p>';
            if($oldpasswords) {
              echo '<p>',str_replace('{0}','&#34;password&#34;',ADM_ERROLDPASSWORDS),'</p>';
            }
          ?></div>
          <div style="text-align: center; margin: 1em;">
            <?php if($_POST['cleardb']) {
              echo '<input type="hidden" name="cleardb" value="1" />';
            } ?>
            <input type="hidden" name="setadmin" value="Restore2" />
            <input type="hidden" name="page" value="backup" />
            <input type="hidden" name="act" value="admin" />
            <input type="hidden" name="from" value="act-admin.page-backup" />
            <input type="submit" value="<?php echo ADM_RESTORE; ?>" name="restorebutton" class="nicebutton" style="width: auto;" />
          </div>
          </form>
          <?php } else { 
            iz_inlineerror(ERR_VERSIONCOMPAT);
          } ?>
          </div>    
  <?php } else {
          echo '<div id="errorbox">',ERR_ERRORTEXT,'&#58;<br />'.$_FILES['backupfile']['error'].'</div>';
        }
  } else { ?> 
      <h1><?php echo ADM_CALSETUP; ?></h1>
      <?php echo ADM_CALSETUPDESC; ?>
      <br /><br /><br />
      <h1><?php echo ADM_LOCAL; ?></h1>
      <?php echo ADM_LOCALDESC; ?>
      <br /><br /><br />
      <h1><?php echo ADM_THEMES; ?></h1>
      <?php echo ADM_THEMESDESC; ?>
      <br /><br /><br />
      <h1><?php echo ADM_USERS; ?></h1>
      <?php echo ADM_USERSDESC; ?>
                  <br /><br /><br />
                  <h1><?php echo ADM_BACKUP; ?></h1>
                  <?php echo ADM_BACKUPDESC; ?>
      <br /><br /><br />
      <h1><?php echo ADM_SYSTEM; ?></h1>
      <?php echo ADM_SYSTEMDESC; ?>
  <?php } ?>
                  </td>
          </tr>
  </table>
  
  </div>
  <?php if($_GET['page'] == 'themes') {
    echo '<script type="text/javascript">
  new Control.ColorPicker("pagebg", { "swatch" : "pagebgpicker" });
  new Control.ColorPicker("calbg", { "swatch" : "calbgpicker" });
  new Control.ColorPicker("occbg", { "swatch" : "occbgpicker" });
  new Control.ColorPicker("occtext", { "swatch" : "occtextpicker" });
  new Control.ColorPicker("blankbg", { "swatch" : "blankbgpicker" });
  new Control.ColorPicker("blanktext", { "swatch" : "blanktextpicker" });
  new Control.ColorPicker("todaybg", { "swatch" : "todaybgpicker" });
  new Control.ColorPicker("todaytext", { "swatch" : "todaytextpicker" });
  new Control.ColorPicker("fillerdays", { "swatch" : "fillerdayspicker" });
  new Control.ColorPicker("calwrappertext", { "swatch" : "calwrappertextpicker" });
  new Control.ColorPicker("boxbg", { "swatch" : "boxbgpicker" });
  new Control.ColorPicker("boxtext", { "swatch" : "boxtextpicker" });
  new Control.ColorPicker("othertext", { "swatch" : "othertextpicker" });
    </script>';
  } elseif($_GET['page'] == 'users') {
    echo '<script type="text/javascript">
    ',$jsfoot,'
    </script>';
  } ?>
  <?php echo '<p class="gentext"><a href="&#x68;&#x74;&#x74;&#112;&#58;&#x2F;&#47;&#x77;&#x77;&#x77;&#46;&#105;&#x7A;&#x65;&#105;&#x74;&#x2E;&#110;&#x75;">iZeit '.IZ_CALVERSION.'</a><br />Copyright &copy;2005 - '.date("Y").' <a href="http://&#000119;&#000119;&#x77;&#46;&#x6c;&#x69;&#x6d;&#000101;&#00052;&#57;&#46;&#x63;&#x6f;&#x6d;">&#72;&#x61;&#x72;&#114;&#121;&#x20;&#74;&#x65;&#x6E;&#x6E;&#101;&#114;&#x77;&#x61;</a><a href="&#x68;&#x74;&#x74;&#112;&#58;&#x2F;&#47;&#x6C;&#x65;&#x67;&#104;&#117;&#x6D;&#x70;&#101;&#x64;&#x2E;&#99;&#x6F;&#109;">&#121;</a></p>'; ?>
  <script type="text/javascript">
  //<![CDATA[
  listen('load', window, function() {
  <?php echo $onload; ?>
      }
  );
  //]]>
  </script>
  </body>
  
  </html>
<?php } else {
  header('Location: ../');
} ?>